package ynu.edu.controller;

import org.springframework.web.bind.annotation.*;
import ynu.edu.entity.User;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/getUserById/{userId}")
    public User GetUserById(@PathVariable("userId") Integer userId){
        User user = new User();
        user.setUserId(userId);
        user.setUserName("小明 from 11000");
        user.setPassWord("123456");
        return user;
    }


    @PostMapping("/create")
    public User createUser(@RequestBody User newUser) {
        return newUser;
    }


    @PutMapping("/update/{userId}")
    public User updateUser(@PathVariable Integer userId, @RequestBody User updatedUser) {
        updatedUser.setUserId(userId); // 确保ID一致
        return updatedUser;
    }


    @DeleteMapping("/delete/{userId}")
    public String deleteUser(@PathVariable Integer userId) {
        return "用户ID为" + userId + "的用户已删除";
    }
}